package day08.ZiXi;

import java.util.ArrayList;
import java.util.Iterator;

public class Collection03 {
    public static void main(String[] args) {
        //创建集合
        ArrayList<String> c = new ArrayList<>();
        //创建元素
        c.add("a");
        c.add("b");
        c.add("c");
        c.add("d");
        c.add("e");
        //Iterator<E> iterator()：返回此集合中元素的迭代器，通过集合的iterator()方法得到
        Iterator<String> it = c.iterator();
        while (it.hasNext()){
            String s = it.next();
            //此处指向谁就删除谁
            if ("d".equals(s)){
                it.remove();
            }
        }
        System.out.println(c);
    }
}
